package ru.rchervot.sanasar.client.view;

import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.Widget;

public class FactoryHeaderViewDefault implements FactoryHeaderView {
	
	private final HandlerManager eventBus;
	
	public FactoryHeaderViewDefault(HandlerManager eventBus) {
		this.eventBus = eventBus;
	}
	
	private HeaderViewDefault headerView;
	@Override
	public HeaderViewDefault getHeaderView() {
		if (headerView == null) {
			headerView = new HeaderViewDefault(getConnectionInfoView());
			HeaderPresenterDefault p = new HeaderPresenterDefault(
					headerView);
			p.bindDisplay();
		}
		
		return headerView;
	}
	
	private ConnectionInfoViewDefault ConnectionInfoView;
	private Widget getConnectionInfoView() {
		if (ConnectionInfoView == null) {
			ConnectionInfoView = new ConnectionInfoViewDefault();
			ConnectionInfoPresenterDefault p = new ConnectionInfoPresenterDefault(
					ConnectionInfoView, eventBus);
			p.bindDisplay();
		}
		
		return ConnectionInfoView;
	}

}
